﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace XBoshiGFS.forms
{
    public partial class StationForm : Form
    {
        public StationSet station { get; set; }
 
        public XBoshiGFSModelContainer context = new XBoshiGFSModelContainer();  


        public StationForm()
        {
            InitializeComponent();

            station = new StationSet();
            station.Id = Guid.NewGuid().ToString();
            station.strName = "新建站"; 
            context.AddToStationSet(station);
            stationSetBindingSource.DataSource = station;

        }

        public StationForm(StationSet p_station)
        {
            InitializeComponent();

            station = p_station;
            context.Attach  (station);
            stationSetBindingSource.DataSource = station;

        }

        
        
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (TBName.Text == "")
            {
                MessageBox.Show("请填写名称！", "提示");
                TBName.Focus();
                return;
            }
            if (TBCode.Text == "")
            {
                MessageBox.Show("请填写代码！", "提示");
                TBCode.Focus();
                return;
            }
                //设置sc的相关信息
                context.AddToStationSet(station);
                context.SaveChanges();
                this.DialogResult = DialogResult.Yes  ;

        }


        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
